/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author usuario
 */
@Entity
@Table(name = "compra")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Compra.findAll", query = "SELECT c FROM Compra c"),
    @NamedQuery(name = "Compra.findByIdcompra", query = "SELECT c FROM Compra c WHERE c.idcompra = :idcompra"),
    @NamedQuery(name = "Compra.findByFechacompra", query = "SELECT c FROM Compra c WHERE c.fechacompra = :fechacompra"),
    @NamedQuery(name = "Compra.findByVlrtotal", query = "SELECT c FROM Compra c WHERE c.vlrtotal = :vlrtotal"),
    @NamedQuery(name = "Compra.findBySaldocompra", query = "SELECT c FROM Compra c WHERE c.saldocompra = :saldocompra")})
public class Compra implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "idcompra")
    private String idcompra;
    @Basic(optional = false)
    @Column(name = "fechacompra")
    @Temporal(TemporalType.DATE)
    private Date fechacompra;
    @Basic(optional = false)
    @Column(name = "vlrtotal")
    private double vlrtotal;
    @Basic(optional = false)
    @Column(name = "saldocompra")
    private double saldocompra;
    @JoinColumn(name = "idproveedor", referencedColumnName = "idproveedor")
    @ManyToOne
    private Proveedor idproveedor;
    @JoinColumn(name = "idempleado", referencedColumnName = "idempleado")
    @ManyToOne(optional = false)
    private Empleado idempleado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "compra")
    private Collection<Pagoproveedor> pagoproveedorCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "compra")
    private Collection<Itemcompra> itemcompraCollection;

    public Compra() {
    }

    public Compra(String idcompra) {
        this.idcompra = idcompra;
    }

    public Compra(String idcompra, Date fechacompra, double vlrtotal, double saldocompra) {
        this.idcompra = idcompra;
        this.fechacompra = fechacompra;
        this.vlrtotal = vlrtotal;
        this.saldocompra = saldocompra;
    }

    public String getIdcompra() {
        return idcompra;
    }

    public void setIdcompra(String idcompra) {
        this.idcompra = idcompra;
    }

    public Date getFechacompra() {
        return fechacompra;
    }

    public void setFechacompra(Date fechacompra) {
        this.fechacompra = fechacompra;
    }

    public double getVlrtotal() {
        return vlrtotal;
    }

    public void setVlrtotal(double vlrtotal) {
        this.vlrtotal = vlrtotal;
    }

    public double getSaldocompra() {
        return saldocompra;
    }

    public void setSaldocompra(double saldocompra) {
        this.saldocompra = saldocompra;
    }

    public Proveedor getIdproveedor() {
        return idproveedor;
    }

    public void setIdproveedor(Proveedor idproveedor) {
        this.idproveedor = idproveedor;
    }

    public Empleado getIdempleado() {
        return idempleado;
    }

    public void setIdempleado(Empleado idempleado) {
        this.idempleado = idempleado;
    }

    @XmlTransient
    public Collection<Pagoproveedor> getPagoproveedorCollection() {
        return pagoproveedorCollection;
    }

    public void setPagoproveedorCollection(Collection<Pagoproveedor> pagoproveedorCollection) {
        this.pagoproveedorCollection = pagoproveedorCollection;
    }

    @XmlTransient
    public Collection<Itemcompra> getItemcompraCollection() {
        return itemcompraCollection;
    }

    public void setItemcompraCollection(Collection<Itemcompra> itemcompraCollection) {
        this.itemcompraCollection = itemcompraCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idcompra != null ? idcompra.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Compra)) {
            return false;
        }
        Compra other = (Compra) object;
        if ((this.idcompra == null && other.idcompra != null) || (this.idcompra != null && !this.idcompra.equals(other.idcompra))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.Compra[ idcompra=" + idcompra + " ]";
    }
    
}
